package com.app.activitys;

import android.os.Bundle;
import android.widget.Toast;

import com.example.applucianokikao.R;
import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayer.Provider;
import com.google.android.youtube.player.YouTubePlayerView;

public class TelaVideo extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener{

	public static final String API_KEY = "AIzaSyAU0pEjQI75mZBf1mCmtUAm2b13_H4_YWk";
	private YouTubePlayer YPlayer;
	private String video="";
	
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tela_video);
 
        Bundle extras = getIntent().getExtras();
        video = extras.getString("video");
        
        YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.tela_youtube_view);
        youTubeView.initialize(API_KEY, this);
    }
	
	@Override
	public void onInitializationFailure(Provider arg0,
			YouTubeInitializationResult arg1) {
		 
		Toast.makeText(this,"Ocorreu algum problema ao iniciar o video.", Toast.LENGTH_LONG).show();
		
	}

	@Override
	public void onInitializationSuccess(Provider arg0, YouTubePlayer arg1,
			boolean arg2) {
		 
		if (!arg2) {
		     YPlayer = arg1;
		     YPlayer.cueVideo(video);   
		     
		}
	}
}
